package com.sun.controller;


import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.sun.mapper.BogusMapper;
import com.sun.pojo.BogusColleges;
import com.sun.pojo.HeannScoreL;
import com.sun.scenario.effect.impl.prism.ps.PPSBlend_SRC_OUTPeer;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import java.io.OutputStreamWriter;
import java.util.Collection;
import java.util.List;
import java.util.Map;

@Controller
public class BogusController {

    @Autowired
    BogusMapper bogusMapper;

    @RequestMapping("/bogus/{pageNo}")
    public Object page(@PathVariable("pageNo") Integer pageNo,
                       Model model
    ) {
        PageHelper.startPage(pageNo,10);
        List<BogusColleges> list = bogusMapper.selectBogusAll();
        PageInfo<BogusColleges> page = new PageInfo<>(list,5);
        model.addAttribute("list",page);
//        model.addAttribute("pageNo1",pageNo1);
//        System.out.println(pageNo1);
//        return page;
        return "bogus/list";
    }


    @RequestMapping("/bogus")
    public String po(@RequestParam(value = "pageNo1",defaultValue = "1") Integer pageNo1,
                     Model model){
        System.out.println(pageNo1);
        PageHelper.startPage(pageNo1,10);
        List<BogusColleges> list = bogusMapper.selectBogusAll();
        PageInfo<BogusColleges> page1 = new PageInfo<>(list,5);
        model.addAttribute("list",page1);
        System.out.println(page1);
        return "bogus/list";
    }
    /*
    *
    *搜索是否野鸡大学
    * */
    @RequestMapping("/ide")
    public String select(@RequestParam("name") String name,
                     Model model){
        System.out.println(name);
//        PageHelper.startPage(1,10);
        List<BogusColleges> list = bogusMapper.selectData(name);
        System.out.println(list);
//        Integer t = bogusMapper.selectCountData(name);
        PageInfo<BogusColleges> page1 = new PageInfo<>(list, 5);
        model.addAttribute("list", page1);
//        System.out.println(page1);
        return "bogus/list";
    }

    @RequestMapping("/bogus/selectType")
    @ResponseBody
    public Object selectNoYear(){
        Collection<Map<String, Integer>> list = bogusMapper.selectType();
        System.out.println(list);
        return list ;
    }
    @RequestMapping("/bogus/selectbogusTop5")
    @ResponseBody
    public Object selectbogusTop5(){
        Collection<Map<String, Integer>> list = bogusMapper.selectbogusTop5();
        System.out.println(list);
        return list ;
    }

    @RequestMapping("/bogus/echarts")
    public String Echarts(){
        return "bogus/Echarts";
    }


}
